<?php
namespace  app\api\model;

use think\Model;
use think\Session;

use fast\Http;


class Weixin extends Model
{
	protected $appid="";
	protected $secret="";
	
	
	public function __construct($appid="",$secret=""){
		$this->appid=$appid;
		$this->secret=$secret;
	}
	public function getAccessToken(){
		$params = [
            'appid'      =>$this->appid,
            'secret'     =>$this->secret,
            'grant_type' => 'client_credential'
        ];
        $ret = Http::sendRequest('https://api.weixin.qq.com/cgi-bin/token', $params, 'GET');
        if ($ret['ret']) {
            $ar = json_decode($ret['msg'], true);
            return $ar;
        }
        return [];
	}
}